//
//  YTRightView.m
//  YUNT
//
//  Created by 小萌 on 2017/11/12.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTRightView.h"

@interface YTRightView()
@property (nonatomic, weak) IBOutlet UIButton *btnHome;
@property (weak, nonatomic) IBOutlet UIButton *btnPhoto;
@property (weak, nonatomic) IBOutlet UIButton *btnCamera;
@property (weak, nonatomic) IBOutlet UIButton *btnSetting;
@property (weak, nonatomic) IBOutlet UIButton *btnFlick;
@end
@implementation YTRightView

- (void)awakeFromNib
{
    [super awakeFromNib];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    if([UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortrait||[UIApplication sharedApplication].statusBarOrientation ==UIInterfaceOrientationPortraitUpsideDown){
        CGFloat widthPadding = (ScreenWidth - 24 -24 - 37 * 4) /3;
        [self.btnHome mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(24);
            make.left.equalTo(self).offset(24);
            make.width.equalTo(@(37));
            make.height.equalTo(@(36));
        }];
        [self.btnFlick mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome.mas_bottom).offset(24);
            make.left.equalTo(self).offset(24);
            make.width.equalTo(@(37));
            make.height.equalTo(@(36));
        }];
        [self.btnPhoto mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome);
            make.left.mas_equalTo(self.btnHome.mas_right).offset(widthPadding);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];
        [self.btnCamera mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome);
            make.left.mas_equalTo(self.btnPhoto.mas_right).offset(widthPadding);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];
        [self.btnSetting mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome);
            make.left.mas_equalTo(self.btnCamera.mas_right).offset(widthPadding);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];
        
    }else{
        CGFloat widthPadding = (ScreenHeight - 24 -24 - 37 * 4) /3;
        [self.btnHome mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(24);
            make.right.equalTo(self).offset(-24);
            make.width.equalTo(@(37));
            make.height.equalTo(@(36));
        }];
        [self.btnFlick mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome);
            make.right.equalTo(self.btnHome.mas_left).offset(-24);
            make.width.equalTo(@(37));
            make.height.equalTo(@(36));
        }];
        [self.btnPhoto mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.btnHome.mas_bottom).offset(widthPadding);
            make.right.mas_equalTo(self.btnHome);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];
        [self.btnCamera mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.btnHome);
            make.top.mas_equalTo(self.btnPhoto.mas_bottom).offset(widthPadding);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];
        [self.btnSetting mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.btnHome);
            make.top.mas_equalTo(self.btnCamera.mas_bottom).offset(widthPadding);
            make.width.equalTo(self.btnHome);
            make.height.equalTo(self.btnHome);
        }];

    }
}
#pragma mark - 点击事件
- (IBAction)clickBtn:(UIButton *)sender {
    
    BlockCallWithOneArg(self.clickhandler, @(sender.tag - 500));
    /*
    if(sender.tag == 500){
        NSLog(@"首页");
    }else if (sender.tag == 501){
        NSLog(@"相机");
    }else if (sender.tag == 502){
        NSLog(@"云台");
    }else if (sender.tag == 503){
        NSLog(@"设置");
    }else if (sender.tag == 504){
        NSLog(@"闪光灯");
    }
     */
}

@end
